{% extends "shared/layout.volt" %}
{% block content %}
    <h1 class="page-header">编辑资源</h1>
    <div class="form-box" style="width: 550px;margin-top: 20px;">
        <form class="form-horizontal" method="post" id="formResourceEdit">
            <input type="hidden" name="resource_id" id="resource_id" value="{{ Model.resource_id }}">
            <div class="form-group">
                <label class="col-sm-3 control-label">资源名称</label>
                <div class="col-sm-9">
                    <input type="text" maxlength="200" name="resource_name" placeholder="资源名称" value="{{ Model.resource_name }}" class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">显示名称</label>
                <div class="col-sm-9">
                    <input type="text" maxlength="200" name="display_name" placeholder="显示名称" value="{{ Model.display_name }}" class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">控制器名称</label>
                <div class="col-sm-9">
                    <input type="text" name="controller_name" placeholder="控制器名称" value="{{ Model.controller_name }}" class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">方法名称</label>
                <div class="col-sm-9">
                    <input type="text" name="action_name" placeholder="方法名称" value="{{ Model.action_name }}" class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">图标类名</label>
                <div class="col-sm-9">
                    <input type="text" name="icon_class" placeholder="图标类名" value="{{ Model.icon_class }}" class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">排序</label>
                <div class="col-sm-9">
                    <input type="text" name="sort_index" placeholder="排序" value="{{ Model.sort_index }}" class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">导航显示</label>
                <div class="col-sm-9">
                    <div class="radio_box">
                        <label for="is_show_menu1" class="enable{{ Model.is_show_menu == 1 ? ' selected' : '' }}">显示</label>
                        <label for="is_show_menu2" class="disable{{ Model.is_show_menu == 0 ? ' selected' : '' }}">不显示</label>
                        <input type="radio" value="1" name="is_show_menu" id="is_show_menu1"{{ Model.is_show_menu == 1 ? ' checked="checked"' : '' }}>
                        <input type="radio" value="0" name="is_show_menu" id="is_show_menu2"{{ Model.is_show_menu == 0 ? ' checked="checked"' : '' }}>
                    </div>
                    <p class="sub-text">选中后会在左侧导航栏显示</p>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                    <button type="submit" class="btn btn-success" data-loading-text="保存中...">确定</button>
                    <button type="button" class="btn btn-default" onclick="window.location=window.document.referrer;">返回</button>
                </div>
            </div>
        </form>
    </div>
{% endblock %}
{% block footer %}
    <script type="text/javascript">
        $(function () {
            $("#formResourceEdit").ajaxForm({
               success : function ($res) {
                   if($res.errCode === 0){
                       $("#resource_id").val($res.data.resource_id)
                       layer.msg('保存成功',{
                           time:1000,
                           icon:1
                       },function () {
                           window.document.location = "{{ url('resource/list') }}"
                       });
                   }else{
                       layer.msg($res.errMsg);
                   }
               }
            });
        });
    </script>
{% endblock %}
